package org.wyl.job51.component;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.wyl.job51.entity.JobInfo;
import org.wyl.job51.mapper.JobInfoMapper;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

/**
 * @author: Mask.m
 * @create: 2021/07/14 20:53
 * @description:
 */
@Component
public class JobPipeline implements Pipeline {

    @Autowired
    private JobInfoMapper jobInfoMapper;

    /**
     * @param resultItems 返回的结果
     * @param task
     */
    @Override
    public void process(ResultItems resultItems, Task task) {
        // 取出数据
        JobInfo jobInfo = resultItems.get("jobInfo");
        System.out.println(JSON.toJSONString(jobInfo));
//        if(null != jobInfo){
//            System.out.println(JSON.toJSONString(jobInfo));
//            jobInfoMapper.insert(jobInfo);
//        }
    }
}